#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+100;
struct Node{
    int nd,nv,na;
}a[MAXN];
int p[MAXN];
int t,n,m,l,v,ans,lst;
int ifneed[MAXN];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int w=1;w<=t;w++){
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>a[i].nd>>a[i].nv>>a[i].na;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        for(int i=1;i<=n;i++){
            if(a[i].nv<v and a[i].na<=0){
                continue;
            }
            for(int j=1;j<=m;j++){
                if(p[j]<a[i].nd){
                    continue;
                }
                double s,ss,sss;
                s=p[j]-a[i].nd;
                ss=sqrt((a[i].nv)*(a[i].nv)+2*a[i].na*s)*1.0;
                if(ss==0){
                    break;
                }
                if(a[i].na>=0){
                    if(ss>v){
                        ifneed[j]=0;
                        ans++;
                        for(int k=j+1;k<=m;k++){
                            ifneed[k]++;
                        }
                        break;
                    }
                }
                else if(a[i].na<0){
                    if(ss>v){
                        ifneed[j]=0;
                        ans++;
                        for(int k=j+1;k<=m;k++){
                            if(ss<v){
                                break;
                            }
                            ifneed[k]++;
                        }
                       break;
                    }
                }
            }
        }
    }
    for(int i=1;i<=m;i++){
        if(ifneed[i]>=1){
            lst++;
        }
    }
    cout<<ans<<" "<<lst;
    return 0;
}
